<template>
  <div class="action-bar">
    
    <div class="chat" @click="chatClick" >
      <i class="action-icon"></i>
      <span class="text">聊天</span>
    </div>
    <div class="price">
      <span class="new">￥{{ currentHouse.finalPrice }}</span>
      <span class="unit">{{ currentHouse.priceMark }}</span>
      <span class="old">{{ currentHouse.productPrice }}</span>
      <div class="reduction">
        <span class="prices">已减免{{ prices }}元</span>
        <span class="detailed">明细</span>
        <img src="@/assets/img/detail/order-detail-icon.png" alt="">
      </div>
    </div>
    <div class="buy">
      <i class="buy-icon"></i>
      <span class="text">预订当前房源</span>
    </div>
  </div>
</template>

<script setup>
  import { ref, computed } from 'vue'
import { useRouter } from 'vue-router';
  const props = defineProps({
    currentHouse: {
      type: Object,
      default: () => ({})
    }
  })

  const price = ref()
  price.value = Number(props.currentHouse.productPrice.slice(1))
  const prices = computed(() => {
    return price.value - props.currentHouse.finalPrice
  })

const router = useRouter()
const chatClick = () =>{
router.push('/message')


}
</script>

<style lang="less" scoped>
  .action-bar {
    position: fixed;
    z-index: 999;
    bottom: 0;
    display: flex;
    align-items: center;
    width: 100%;
    height: 60px;
    box-sizing: border-box;
    border-top: 1px solid #f7f9fb;
    background-color: #fff;

    .chat {
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 50px;
      margin: 6px 0;
      border-right: 1px solid #ddd;

      .text {
        margin-top: 5px;
        font-size: 12px;
      }
    }

    .price {
      flex: 1;
      padding: 0 20px;
      font-size: 12px;
      color: #666;

      .new {
        font-size: 16px;
        font-weight: 700;
        color: #ff9645;
      }

      .unit {
        margin: 0 6px;
      }

      .old {
        text-decoration: line-through;
      }
      .reduction{
        margin-top: 3px;
        display: flex;
        align-items: center;
        
        .prices {
        height: 15px;
        display: inline-block;
        background: rgba(255, 150, 69, 0.1);
        border-radius: 2px;
        padding: 2px;
        font-size: 10px;
        color: #ff9645;
      }
      .detailed{
        color: #ff9645;
        margin-left: 5px;
      }
      img{
        width: 7px;
        height: 7px;
        margin-left:2px;
      }
      }
    }

    .buy {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 150px;
      height: 100%;
      background: linear-gradient(90deg, #fa8c1d, #fcaf3f);

      .text {
        font-size: 18px;
        color: #fff;
        margin-left: 5px;
      }
    }
  }
  .action-icon {
    display: inline-block;
    width: 17px;
    height: 17px;
    background: url(@/assets/img/detail/icon_chat.png) 0 0 / 100% 100%;
  }

  .buy-icon {
    display: block;
    width: 14px;
    height: 17px;
    background: url(@/assets/img/detail/icon_order.png) 0 0 / 100% 100%;
  }
</style>
